Skip to content

Conversation

jorisvandenbossche
Copy link
Member

Backport of #60116

Comment on lines 931 to 935
# For backwards compatibility, we let Index do its normal type
# inference, _except_ for if if infers from object to bool.
idx = Index(keys)
if idx.dtype == bool and keys.dtype == object:
if idx.dtype in [bool, "string"] and keys.dtype == object:
idx = idx.astype(object)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed for 2.3.x in addition to the changes on main, because here the Index(..) is not yet updated to idx = Index(keys, dtype=keys.dtype) after the deprecation enforcement

@jorisvandenbossche jorisvandenbossche merged commit ce56f2e into pandas-dev:2.3.x Nov 4, 2024
57 of 62 checks passed
@jorisvandenbossche jorisvandenbossche deleted the backport-60116 branch November 4, 2024 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant